import instance from "../../url/chat.js";
const get_double_message_by_room_id = async (room_id, user_id, type = 0, limit = 1,room_stream=0) => {
    return await instance.get(`/ws/get/message/double/by_single?room_id=${room_id}&user_id=${user_id}&type=${type}&limit=${limit}&room_stream=${room_stream}`)
        .then(response => {
        return response
        })
}
const get_group_message_by_room_id = async (room_id, user_id, type = 0, limit = 1,room_stream=0) => {
    return await instance.get(`/ws/get/message/group/by_single?room_id=${room_id}&user_id=${user_id}&type=${type}&limit=${limit}&room_stream=${room_stream}`)
        .then(response => {
        return response
    })
}

// 这两个主要用于直接窗口聊天的轮询,提高交互效果减少其他轮询次数
const fetch_double_by_room_id = async (room_id, user_id) => {
    return await instance.get(`/ws/get/message/by_single?room_id=${room_id}&user_id=${user_id}`)
        .then(response => {
        return response
    })
}
const fetch_group_by_room_id = async (room_id, user_id) => {
    return await instance.get(`/ws/get/message/by_single?room_id=${room_id}&user_id=${user_id}`)
        .then(response => {
            return response
        })
}
const fetch_double_all = async (room_info, user_id) => {
    return await instance.post(`/ws/get/message/double/all?user_id=${user_id}`,room_info)
        .then(response => {
            return response
        })  
}
const fetch_group_all = async (room_info, user_id) =>{
    return await instance.post(`/ws/get/message/group/all?user_id=${user_id}`,room_info)
        .then(response => {
            return response
        })
}






export { 
    get_double_message_by_room_id,get_group_message_by_room_id,
    fetch_double_by_room_id, fetch_group_by_room_id,
    fetch_double_all, fetch_group_all
}